<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>Home</title>
    <link rel="stylesheet" th:href="@{static/css/layui.css}">
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
    <div class="layui-header">
        <div class="layui-logo">运动会管理系统</div>
        <!-- 头部区域（可配合layui已有的水平导航） -->
        <ul class="layui-nav layui-layout-left">

        </ul>
        <ul class="layui-nav layui-layout-right">
            <div th:if="${session.user}">
                <li class="layui-nav-item">
                    <a href="javascript:;">
                        <i class="layui-icon layui-icon-user" style="font-size: 15px"></i>
                        <span th:text="${session.user.getNum()}">unknown</span>
                    </a>
                    <dl class="layui-nav-child">
                        <dd th:if="${session.user.getIdentity().equals('2')}"><a th:href="@{userinfo}">基本资料</a></dd>
                        <dd><a th:href="@{/toPage(url=rePassword)}">修改密码</a></dd>
                    </dl>
                </li>
                <li class="layui-nav-item"><a href="user/logout">退出</a></li>
            </div>
            <div th:unless="${session.user}">
                <li class="layui-nav-item"><a th:href="@{/toPage(url=login)}">登录</a></li>
            </div>
        </ul>
    </div>

    <div class="layui-side layui-bg-black">
        <div class="layui-side-scroll">
            <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
            <ul class="layui-nav layui-nav-tree layui-inline" lay-filter="test" style="margin-right: 10px;">
                <li class="layui-nav-item"><a href="/sports">主页</a></li>
                <li class="layui-nav-item layui-nav-itemed">
                    <a href="javascript:;">当前赛况</a>
                    <dl class="layui-nav-child">
                        <dd><a th:href="@{/toPage(url=scoreSituation)}">田赛</a></dd>
                        <dd><a th:href="@{/toPage(url=scoreSituationJ)}">径赛</a></dd>
                    </dl>
                </li>
                <div th:if="${session.user}">
                    <li class="layui-nav-item" th:if="${session.user.getIdentity().equals('2')}"><a th:href="@{/toPage(url=signup)}">我要报名</a></li>
                    <li class="layui-nav-item" th:if="${session.user.getIdentity().equals('2')}"><a th:href="@{/toPage(url=myRegistration)}">我的报名</a></li>
                    <li class="layui-nav-item layui-nav-itemed" th:if="${session.user.getIdentity().equals('0') || session.user.getIdentity().equals('1')}">
                        <a href="javascript:;">上传成绩</a>
                        <dl class="layui-nav-child">
                            <dd><a th:href="@{/toPage(url=scoreEntryT)}">田赛</a></dd>
                            <dd><a th:href="@{/toPage(url=scoreEntryJ)}">径赛</a></dd>
                        </dl>
                    </li>
                    <li class="layui-nav-item" th:if="${session.user.getIdentity().equals('1')}"><a th:href="@{/toPage(url=registrationReview)}">报名审核</a></li>
                    <li class="layui-nav-item" th:if="${session.user.getIdentity().equals('1')}"><a th:href="@{/toPage(url=perManagement)}">人员管理</a></li>
                    <li class="layui-nav-item" th:if="${session.user.getIdentity().equals('1')}"><a th:href="@{/toPage(url=noticeManage)}">公告管理</a></li>
                    <li class="layui-nav-item" th:if="${session.user.getIdentity().equals('1')}"><a th:href="@{/toPage(url=volunteer)}">志愿者名单</a></li>
                    <li class="layui-nav-item" th:if="${session.user.getIdentity().equals('1')}"><a th:href="@{/toPage(url=projectManage)}">项目</a></li>
                </div>
            </ul>
        </div>
    </div>

    <div class="layui-body">
        <!-- 内容主体区域 -->

        <div class="layui-row">
            <div class="layui-col-md4 layui-col-md-offset5">
                <h1 style="height: 70px;">个人信息</h1>
            </div>
        </div>


        <div class="layui-col-md4 layui-col-md-offset2">

            <div class="layui-form-item">
                <label class="layui-form-label">学号</label>
                <div class="layui-input-inline">
                    <input type="text" id="studentID" name="studentID"
                           disabled th:value="${student.getStuNum()}"
                           autocomplete="off" class="layui-input"></div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">姓名</label>
                <div class="layui-input-inline">
                    <input type="text" id="fullName" name="fullName"
                           disabled th:value="${student.getStuName()}"
                           autocomplete="off" class="layui-input"></div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">性别</label>
                <div class="layui-input-inline">
                    <input type="text" id="Sex" name="Sex"
                           disabled th:value="${student.getStuSex()}"
                           autocomplete="off" class="layui-input"></div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">入学日期</label>
                <div class="layui-input-inline">
                    <input type="text" id="enrollmentDate" name="enrollmentDate"
                           disabled th:value="${student.getEnrollmentDate()}"
                           class="layui-input" style="width: 300px"></div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">学院</label>
                <div class="layui-input-inline">
                    <input type="text" id="college" name="college"
                           disabled th:value="${college}"
                           autocomplete="off" class="layui-input"></div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">班级</label>
                <div class="layui-input-inline">
                    <input type="text" id="class" name="class"
                           disabled th:value="${student.getStuClass()}"
                           autocomplete="off" class="layui-input"></div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">邮箱</label>
                <div class="layui-input-inline">
                    <input type="text" id="email" name="email"
                           th:value="${student.getStuEmail()}"
                           autocomplete="off" class="layui-input"></div>
                <button class="layui-btn" id="email-btn">修改邮箱</button>
                <span id="email-validator-error"></span>
            </div>
        </div>

    </div>

</div>

<script th:src="@{static/layui.js}"></script>
<script th:src="@{static/jquery.js}"></script>

<script>
    layui.use('layer', function () {
        var layer = layui.layer;
        $('#email-btn').click(function () {
            let new_email = $('#email').val();
            let stuNum = $('#studentID').val();
            var reg = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/g;
            if (!reg.test($("#email").val())) {
                layer.msg("请输入正确的email！");
                $("#email").focus();
            } else {
                $.post("user/changeEmail", {email: new_email, id: stuNum}, function (result) {
                    layer.msg(result)
                })
            }
        })
    });

</script>

</body>
</html>
